package scms.service.order;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.databind.ObjectMapper;

import lac.framework.common.message.ExceptionResult;
import lac.framework.common.message.Result;
import lac.framework.core.model.ModelLogicBean;
import lac.framework.security.session.AccountUtil;
import scms.service.api.StockService;

@Service
public class UpdateStockLogicBean extends ModelLogicBean<Map<String, Object>>{

	@Autowired
	private ObjectMapper om;
	
	@Autowired
	private StockService stockService;
	@Override
	public void doLogic() throws Exception {
		System.out.println(AccountUtil.getToken());
		Map<String,Object> data = getModelData();
		Map<String,Object> result = (Map<String,Object>)stockService.update(data);
		ExceptionResult result2 = om.readValue(om.writeValueAsString(result), ExceptionResult.class) ;
		if(!result2.isSuccess()){
			ExceptionResult er =(ExceptionResult)result2;
			throw new RuntimeException(er.getExceptionMessage());
		}
		System.out.println();
	}

}
